{template 'common/header'}
<style>
	.account-stat{overflow:hidden; color:#666;}
	.account-stat .account-stat-btn{width:100%; overflow:hidden;}
	.account-stat .account-stat-btn > div{text-align:center; margin-bottom:5px;float:left;width:33%; height:80px; padding-top:10px;font-size:16px; border-left:1px #DDD solid;}
	.account-stat .account-stat-btn > div:first-child{border-left:0;}
	.account-stat .account-stat-btn > div span{display:block; font-size:30px; font-weight:bold}
</style>
<ul class="nav nav-tabs">
	<li class="active">
	<a href="#">结算中心</a>
	</li>
</ul>

<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="post" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="cy163_salesjl" />
				<input type="hidden" name="do" value="jiesuan" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">开始时间</label>
					<div class="col-sm-5 col-xs-12">
						{php echo tpl_form_field_date('starttime',$starttime,true);}
					</div>
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">结束时间</label>
					<div class="col-sm-5 col-xs-12">
						{php echo tpl_form_field_date('endtime',$endtime,true);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">订单状态</label>
					<div class="col-sm-5 col-xs-12">
						<select name="status" class="form-control">
							<option value="100" {if $status == 100}selected="selected"{/if}>全部订单</option>
							<option value="0" {if $status == 0}selected="selected"{/if}>未付款订单</option>
							<option value="1" {if $status == 1}selected="selected"{/if}>已付款订单</option>
							<option value="2" {if $status == 2}selected="selected"{/if}>已发货订单</option>
							<option value="4" {if $status == 4}selected="selected"{/if}>已完成订单</option>
						</select>
					</div>
					<div class="col-sm-5 col-xs-12">
						<input class="form-control" name="merkeyword" type="text" value="{$_GPC['merkeyword']}" placeholder="可查询代理商店铺名、真实姓名、手机号">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
					<div class="col-sm-7 col-xs-12">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<button name="export" value="export" class="btn btn-default"><i class="fa fa-download"></i> 导出结算表</button>
						<button type="button" class="btn btn-default">总订单数：{$total}</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	
	<div class="panel panel-default" style="padding:1em;">
		<div class="account-stat">
			<div class="account-stat-btn">
				<div>总订单数 <span>{$total}</span></div>
				<div>总金额 <span>{$allprice}</span></div>
				<div>总支出佣金<span>{$alllirun}</span></div>
			</div>
		</div>
	</div>
	
	<div class="panel panel-default">
		<div class="panel-heading">结算</div>
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
				<tr>
					<th style="width:10%;">订单号</th>
					<th style="width:20%;">商品名称</th>
					<th style="width:8%;">数量</th>
					<th style="width:8%;">成本价</th>
					<th style="width:8%;">代理价</th>
					<th style="width:8%;">销售价</th>
					<th style="width:8%;">利润</th>
					<th style="width:8%;">佣金</th>
					<th style="text-align:right;">代理商家</th>
				</tr>
				</thead>
				<tbody>
				{loop $list $row}
					{loop $row['goodslist'] $item}
					<tr>
						<td>{$row['ordersn']} </td>
						<td>{$item['goodsname']}{if $item['optionname']}<span style="color:red;">[{$item['optionname']}]</span>{/if}</td>
						<td>{$item['total']}</td>
						<td>{php echo $item['cbprice']*$item['total']}</td>
						<td>{php echo $item['dlprice']*$item['total']}</td>
						<td>{php echo $item['price']*$item['total']} </td>
						<td>{php echo $item['dlprice']*$item['total']-$item['cbprice']*$item['total']} </td>
						<td>{$item['lirun']} </td>
						<td style="text-align:right;">{$row['merchant']['name']}</td>
					</tr>
					{/loop}
				{/loop}
				</tbody>
			</table>
		</div>
	</div>
	{$pager}
</div>
<script type="text/javascript">
	require(['daterangepicker'], function($){
		$('.daterange').on('apply.daterangepicker', function(ev, picker) {
			$('#form1')[0].submit();
		});
	});
</script>
{template 'common/footer'}